<template>
  <div class="container">
    <van-nav-bar title="费用详情" fixed @click-left="onClickLeft">
      <van-icon name="arrow-left" slot="left" color="#333" size="0.6rem" />
    </van-nav-bar>
    <div class="box_added box-Tab">
      <!-- <div class="checkSteper">
        <ul>
          <li
            :class="TabArr.filter(item => item == '精拼报价').length ? 'active' : ''"
            @click="Tab('精拼报价')"
          >精拼报价</li>
          <p>|</p>
          <li
            :class="TabArr.filter(item => item == '人工报价').length? 'active' : ''"
            @click="Tab('人工报价')"
          >人工报价</li>
        </ul>
      </div> -->
    </div>
    <div v-if="TabArr[0]=='人工报价'" style="padding:0 18px 0 18px;boxSizing:borderBox;">
      <van-cell-group class="count">
        <van-cell title="上游费用" />
        <van-cell title="是否提货" :value="delivery" is-link @click="sheetType" />
        <van-field
          v-model="deliveryMoney"
          label="提货费"
          v-if="sheetTypeVal"
          type="number"
          placeholder="请输入"
          input-align="right"
        />
        <van-cell title="是否送货" :value="deliveryout" is-link @click="showT" />
        <van-field
          v-model="deliveryoutMoney"
          v-if="sheetTypeTVal"
          label="送货费"
          placeholder="请输入"
          type="number"
          input-align="right"
        />
        <van-field
          v-model="transportation"
          label="干线运输费"
          type="number"
          placeholder="请输入"
          input-align="right"
        />
        <!-- <van-field
          v-model="prescriptionTimer"
          label="时效"
          type="number"
          placeholder="请输入"
          input-align="right"
        /> -->
      </van-cell-group>
      <!-- <van-cell-group class="count">
        <van-cell title="下游费用" />
        <van-cell title="干线承运商" :value="mainlinePeople" is-link @click="mainpeople" />
        <van-cell
          title="直客承运商"
          v-if="mainlinePeople == '直客承运商' ? true : false"
          required
          @click="ismainline"
          :value="mainMan"
          is-link
        />
        <van-field
          label="承运商联系人"
          v-if="mainlinePeople == '直客承运商' ? true : false"
          required
          v-model="mainuser"
          placeholder="请输入"
          input-align="right"
        />
        <van-field
          v-model="mainlinePeopleTel"
          v-if="mainlinePeople == '直客承运商' ? true : false"
          required
          label="联系人手机号"
          placeholder="请输入"
          type="number"
          maxlength="11"
          input-align="right"
        />
        <van-field
          v-model="mainlinePeopleOrder"
          v-if="mainlinePeople == '直客承运商' ? true : false"
          required
          label="承运商运单号"
          placeholder="请输入"
          input-align="right"
        />
        <van-field
          v-model="transportationfeepayable"
          label="干线运输费应付"
          placeholder="请输入"
          input-align="right"
          type="number"
        />

        <van-cell title="提货承运商" :value="pickup" is-link @click="Tman" />
        <template>
          <van-field
            v-model="carrierPickUp"
            type="number"
            label="提货费"
            input-align="right"
            placeholder="请输入"
          />
        </template>
        <van-cell title="送货承运商" :value="pickdown" is-link @click="Sman" />
        <template>
          <van-field
            v-model="carrierSend"
            type="number"
            label="送货费"
            input-align="right"
            placeholder="请输入"
          />
        </template>
       
      </van-cell-group> -->
       <!-- <van-field v-model="payable" label="运输费应付" placeholder="请输入" input-align="right" /> -->
      <van-action-sheet
        v-model="showType"
        :actions="actions"
        cancel-text="取消"
        close-on-click-action
        @select="onSelect"
      />
      <van-action-sheet
        v-model="show"
        :actions="actions"
        cancel-text="取消"
        close-on-click-action
        @select="onSelectT"
      />
      <van-action-sheet v-model="mainline" title="干线承运商">
        <div class="content">
          <div class="box_added">
            <div class="checkSteper">
              <ul>
                <li
                  :class="checkArr.filter(item => item == '精拼').length ? 'active' : ''"
                  @click="onclick('精拼')"
                >精拼</li>
                <li
                  :class="checkArr.filter(item => item == '直客承运商').length? 'active' : ''"
                  @click="onclick('直客承运商')"
                >直客承运商</li>
              </ul>
            </div>
          </div>
        </div>
      </van-action-sheet>
      <van-action-sheet v-model="Tpeople" title="提货承运商">
        <div class="content">
          <div class="box_added">
            <div class="checkSteper">
              <ul v-if="showFlag">
                <li
                  :class="TpeoplecheckArr.filter(item => item == '短驳').length ? 'active' : ''"
                  @click="Tpeopleonclick('短驳')"
                >短驳</li>
                <li
                  :class="TpeoplecheckArr.filter(item => item == '精拼承运商').length? 'active' : ''"
                  @click="Tpeopleonclick('精拼承运商')"
                >精拼承运商</li>
              </ul>
              <ul v-else>
                <li
                  :class="SpeoplecheckArr.filter(item => item == '短驳').length ? 'active' : ''"
                  @click="Tpeopleonclick('短驳')"
                >短驳</li>
                <li
                  :class="SpeoplecheckArr.filter(item => item == '直客承运商').length? 'active' : ''"
                  @click="Tpeopleonclick('直客承运商')"
                >直客承运商</li>
              </ul>
            </div>
          </div>
        </div>
      </van-action-sheet>
      <van-action-sheet v-model="Speople" title="送货承运商">
        <div class="content">
          <div class="box_added">
            <div class="checkSteper">
              <ul v-if="showFlag">
                <li
                  :class="SpeoplecheckArr.filter(item => item == '短驳').length ? 'active' : ''"
                  @click="Speopleonclick('短驳')"
                >短驳</li>
                <li
                  :class="SpeoplecheckArr.filter(item => item == '精拼承运商').length? 'active' : ''"
                  @click="Speopleonclick('精拼承运商')"
                >精拼承运商</li>
              </ul>
              <ul v-else>
                <li
                  :class="SpeoplecheckArr.filter(item => item == '短驳').length ? 'active' : ''"
                  @click="Speopleonclick('短驳')"
                >短驳</li>
                <li
                  :class="SpeoplecheckArr.filter(item => item == '直客承运商').length? 'active' : ''"
                  @click="Speopleonclick('直客承运商')"
                >直客承运商</li>
              </ul>
            </div>
          </div>
        </div>
      </van-action-sheet>
    </div>
    <div v-else>
      <van-cell-group class="count">
        <van-field :value="`￥${reaches}`" :disabled="true" label="上游应收合计" input-align="right" />
        <van-field :value="`￥${reachesT}`" :disabled="true" label="提货费" input-align="right" />
        <van-field :value="`￥${reachesS}`" :disabled="true" label="送货费" input-align="right" />
        <van-field :value="`￥${reachesG}`" :disabled="true" label="干线运输费" input-align="right" />
        <van-field
          :value="`${prescriptionTimerP}`"
          :disabled="true"
          label="时效"
          input-align="right"
        />
      </van-cell-group>
      <van-cell-group class="count">
        <van-field
          :value="`￥${prescriptionMoney}`"
          :disabled="true"
          label="下游应付合计"
          input-align="right"
        />
        <van-field :value="`￥${prescriptionT}`" :disabled="true" label="提货费" input-align="right" />
        <van-field :value="`￥${prescriptionS}`" :disabled="true" label="送货费" input-align="right" />
        <van-field :value="`￥${prescriptionG}`" :disabled="true" label="干线运输费" input-align="right" />
      </van-cell-group>
    </div>
    <div class="buton">
      <van-button class="butonO" type="primary" size="large" @click="onClickLeft">取消</van-button>
      <van-button class="butonT" type="primary" @click="onOK" size="large">确定</van-button>
    </div>
    <CarriageT :flag="showCarriage" @backpage="backpage" @Isflag="Isflag" />
  </div>
</template>

<script>
import Vue from "vue";
import { getPrices, getContractPrice } from "@/api/add";
import { Toast, DatetimePicker, Popup } from "vant";
import CarriageT from "@/views/carriageT";
Vue.use(DatetimePicker);
Vue.use(Popup);
export default {
  data() {
    return {
      currentDate: "",
      minDate: new Date(2020, 0, 1),
      maxDate: new Date(2030, 10, 1),
      currentDate: new Date(),
      prescriptionTimerP: 0,
      prescriptionT: 0,
      prescriptionS: 0,
      prescriptionG: 0,
      checkArr: [],
      delivery: "请选择",
      deliveryMoney: 0,
      deliveryout: "请选择",
      deliveryoutMoney: 0,
      transportation: "",
      prescriptionTimer: "",
      prescriptionMoney: "",
      mainlinePeople: "请选择",
      showtimer: false,
      show: false,
      showType: false,
      mainline: false,
      sheetTypeVal: null,
      sheetTypeTVal: null,
      Tpeople: false,
      Speople: false,
      mainlinePeopleTel: "",
      mainlinePeopleOrder: "",
      mainMan: "请输入",
      mainuser: "",
      TpeoplecheckArr: [],
      SpeoplecheckArr: [],
      payable: "",
      showFlag: true,
      transportationfeepayable: "",
      pickup: "请选择",
      pickdown: "请选择",
      actions: [
        { name: "否", index: 0 },
        { name: "是", index: 1 },
      ],
      showCarriage: false,
      query: {},
      TabArr: ["人工报价"],
      contractPriceRemark: "",
      reaches: 0,
      reachesT: 0,
      reachesS: 0,
      reachesG: 0,
      reachesTimer: "-",
      kaPickup: 0, // 人工上游是否提货
      KaDelivery: 0, // 人工上游是否送货
      kaArSend: 0, // 人工上游发货费
      kaArPickUp: 0, // 人工上游提货费
      kaArFreight: 0, // 人工上游干线运输
      priceTime: 0, // 人工上游时效
      PushPlatformPc: 0, // 人工干线承运商
      kaCarrierCompanyName: "", // 人工下游直客承运商名称
      kaCarrierContactName: "", // 人工下游直客承运商联系人
      kaCarrierContactMobile: "", // 人工下游直客联系人手机号
      carrierNumber: "", // 人工下游直客承运商运单号
      carrierPrice: "", // 人工下游干线运输
      kaIspickUp: 0, // 人工下游是否提货
      kaIssend: 0, // 人工下游是否送货
      carrierPickUp: null, //  人工下游提货费
      carrierSend: null, // 人工下游送货费
      kaCarrierId: "", // 人工报价承运商id
    };
  },
  watch: {
    deliveryMoney(val) {
      // 人工上游提货
      console.log(val);
      this.kaArPickUp = val;
    },
    sheetTypeTVal(val) {
      // 人工上游送货
      this.kaArSend = val;
    },
    transportation(val) {
      // 上游干线运输
      this.kaArFreight = val;
    },
    prescriptionTimer(val) {
      // 人工上游时效
      this.priceTime = val;
    },
    transportationfeepayable(val) {
      // 人工下游干线运输费
      this.carrierPrice = val;
    },
    mainlinePeopleOrder(val) {
      this.carrierNumber = val;
    },
    deliveryoutMoney(val) {
      this.kaArSend = val;
    },
  },
  components: {
    CarriageT,
  },
  mounted() {
 this.checkArr = ["精拼"];
    this.mainlinePeople = this.checkArr[0];
    this.PushPlatformPc = 1;
    this.kaCarrierCompanyName = "";
    this.kaCarrierContactName = "";
    this.kaCarrierContactMobile = "";
    this.carrierNumber = "";
    this.showFlag = true;

    this.SpeoplecheckArr = [];
    this.SpeoplecheckArr.push("短驳");
    this.pickdown = this.SpeoplecheckArr[0];
    this.kaIssend = 0;
    this.carrierSend = null;

    this.TpeoplecheckArr = ['短驳'];
    this.pickup = this.TpeoplecheckArr[0];
    this.Tpeople = false;

    this.kaIspickUp = 0;
    this.carrierPickUp = null;

    this.delivery = '是';
      this.sheetTypeVal = 1;
      this.kaPickup = 1;

      this.deliveryout = '是';
      this.sheetTypeTVal = 1;
      this.KaDelivery = 1;

    this.query = this.$router.history.current.query;
    if (JSON.parse(sessionStorage.getItem("feed")) != null) {
      let feed = JSON.parse(sessionStorage.getItem("feed"));
      this.kaPickup = feed.kaPickup; // 人工上游是否提货
      if (feed.kaPickup == 1) {
        this.delivery = "是";
        this.sheetTypeVal = feed.kaPickup;
      } else {
        this.delivery = "否";
      }
      this.kaArPickUp = feed.kaArPickUp; // 人工上游提货费
      this.deliveryMoney = feed.kaArPickUp;

      this.KaDelivery = feed.KaDelivery; // 人工上游是否送货
      if (feed.KaDelivery == 1) {
        this.deliveryout = "是";
        this.sheetTypeTVal = feed.KaDelivery;
      } else {
        this.deliveryout = "否";
      }
      this.kaArSend = feed.kaArSend; // 人工上游发货费
      this.deliveryoutMoney = feed.kaArSend;
      this.kaArFreight = feed.kaArFreight; // 人工上游干线运输
      this.transportation = feed.kaArFreight;

      this.priceTime = feed.priceTime; // 人工上游时效
      this.prescriptionTimer = feed.priceTime;
      this.TabArr = feed.TabArr;
      if (this.TabArr[0] == "精拼报价") {
        this.Tab("精拼报价");
      }
      this.pushPlatformPc = feed.pushPlatformPc; // 人工干线承运商
      if (feed.pushPlatform == 1) {
        this.mainlinePeople = "精拼";
        this.checkArr = ["精拼"];
      } else if (feed.pushPlatform == 3) {
        this.mainlinePeople = "直客承运商";
        this.checkArr = ["直客承运商"];
      }

      if (JSON.parse(sessionStorage.getItem("deliver_checkArr"))!=null) {
        let deliver = JSON.parse(sessionStorage.getItem("deliver_checkArr"));
        if (deliver.filter((item) => item == "需要提货").length) {
          this.delivery = "是";
          this.sheetTypeVal = 1;
        }else{
          this.delivery = "否";
          this.sheetTypeVal = 0;
        }
      }
      if (JSON.parse(sessionStorage.getItem("receiving_checkArr"))!=null) {
        let receiving = JSON.parse(sessionStorage.getItem("receiving_checkArr"));
        if (receiving.filter((item) => item == "需要送货").length) {
          receiving.push("需要送货");
          this.deliveryout = "是";
          this.sheetTypeTVal = 1;
        }else{
          this.deliveryout = "否";
          this.sheetTypeTVal = 0;
        }
      }

      this.kaCarrierId = feed.kaCarrierCompanyName;
      this.kaCarrierCompanyName = feed.kaCarrierCompanyName; // 人工下游直客承运商名称
      this.mainMan = feed.kaCarrierCompanyName;
      this.kaCarrierContactName = feed.kaCarrierContactName; // 人工下游直客承运商联系人
      this.mainuser = feed.kaCarrierContactName;
      this.kaCarrierContactMobile = feed.kaCarrierContactMobile; // 人工下游直客联系人手机号
      this.mainlinePeopleTel = feed.kaCarrierContactMobile;
      this.carrierNumber = feed.carrierNumber; // 人工下游直客承运商运单号
      this.mainlinePeopleOrder = feed.carrierNumber;
      this.carrierPrice = feed.carrierPrice; // 人工下游干线运输
      this.transportationfeepayable = feed.carrierPrice;
      this.kaIspickUp = feed.kaIspickUp; // 人工下游是否提货
      if (feed.kaIspickUp == 0) {
        this.pickup = "短驳";
        this.TpeoplecheckArr = ["短驳"];
      } else if (feed.kaIspickUp == 1 && feed.PushPlatformPc == 1) {
        this.pickup = "精拼承运商";
        this.TpeoplecheckArr = ["精拼承运商"];
        this.showFlag = true;
      } else if (feed.kaIspickUp == 1 && feed.PushPlatformPc == 3) {
        this.pickup = "直客承运商";
        this.TpeoplecheckArr = ["直客承运商"];
        this.showFlag = false;
      }
      this.kaIssend = feed.kaIssend; // 人工下游是否送货
      if (feed.kaIssend == 0) {
        this.pickdown = "短驳";
        this.SpeoplecheckArr = ["短驳"];
      } else if (feed.kaIssend == 1 && feed.PushPlatformPc == 1) {
        this.pickdown = "精拼承运商";
        this.SpeoplecheckArr = ["精拼承运商"];
        this.showFlag = true;
      } else if (feed.kaIssend == 1 && feed.PushPlatformPc == 3) {
        this.pickdown = "直客承运商";
        this.SpeoplecheckArr = ["直客承运商"];
        this.showFlag = false;
      }
      this.carrierPickUp = feed.carrierPickUp; //  人工下游提货费
      this.carrierSend = feed.carrierSend; // 人工下游送货费
    } else{
      if (JSON.parse(sessionStorage.getItem("deliver_checkArr"))!=null) {
        let deliver = JSON.parse(sessionStorage.getItem("deliver_checkArr"));
        if (deliver.filter((item) => item == "需要提货").length) {
          this.delivery = "是";
          this.sheetTypeVal = 1;
        }else{
          this.delivery = "否";
          this.sheetTypeVal = 0;
        }
      }
      if (JSON.parse(sessionStorage.getItem("receiving_checkArr"))!=null) {
        let receiving = JSON.parse(sessionStorage.getItem("receiving_checkArr"));
        if (receiving.filter((item) => item == "需要送货").length) {
          receiving.push("需要送货");
          this.deliveryout = "是";
          this.sheetTypeTVal = 1;
        }else{
          this.deliveryout = "否";
          this.sheetTypeTVal = 0;
        }
      }
      let orderinfo = [];
    let num = 0;
    let kgs = 0;
    let m3s = 0;
    if (!JSON.parse(sessionStorage.getItem("deliver"))) {
      Toast("请将发货地址填写完成再来查看！");
    } else if (!JSON.parse(sessionStorage.getItem("receiving"))) {
      Toast("请将收货地址填写完成再来查看！");
    } else {
      if (JSON.parse(sessionStorage.getItem("orderInfo"))) {
        orderinfo = JSON.parse(sessionStorage.getItem("orderInfo"));
        JSON.parse(sessionStorage.getItem("orderInfo")).map((item) => {
          num += Number(item.KaQuantity);
          kgs += Number(item.KaWeightKg);
          m3s += Number(item.KaVolume);
        });
      }
      let receiving = JSON.parse(sessionStorage.getItem("receiving"));
      let deliver = JSON.parse(sessionStorage.getItem("deliver"));
      console.log(this.$router.history.current.query.kauserId);
      if(this.$router.history.current.query.state != 1){
      let list = {
        KaGoodsTypeList: orderinfo || [],
        KaGoodValues: 0, // 报价声明
        KaVolume: m3s,
        KaWeightKg: kgs,
        CneeAreaCode: receiving.KaUabArea,
        CneeProvinceCode: receiving.KaUabProvince,
        CneeCityCode: receiving.KaUabCity,
        ShrpAreaCode: deliver.KaUabArea,
        ShrpProvinceName: deliver.KaUabProvince,
        ShrpCityCode: deliver.KaUabCity,
        KaQuantity: num,
        LotteryID: "",
        KaSource: 7,
        KaUserId: this.$router.history.current.query.kauserId,
        stopOverList: JSON.parse(sessionStorage.getItem("stopOverList")).reverse(),
        kaGoodsTypeList: JSON.parse(sessionStorage.getItem("orderInfo")), // 货物清单
        userContractId:this.$router.history.current.query.kaUserContractId,

      };
      if(this.$router.history.current.query.kaUserContractStatus == -1){
        getPrices(list).then((res) => {
          this.deliveryMoney = res.data.kaArPickUp;
          this.deliveryoutMoney = res.data.kaArSend;
          this.transportation = res.data.linePrice;
          this.reachesTimer = res.data.arriveTime;
          this.prescriptionTimerP = res.data.arriveTime;
          this.carrierPickUp = res.data.downStreamPickPay;
          this.carrierSend = res.data.downStreamSendPay;
          this.transportationfeepayable = res.data.downStreamLinePay;
          this.contractPriceRemark = res.data.contractPriceRemark
        });
      }else{
        getContractPrice(list).then(res =>{
          this.deliveryMoney = res.data.kaArPickUp;
          this.deliveryoutMoney = res.data.kaArSend;
          this.transportation = res.data.linePrice;
          this.reachesTimer = res.data.arriveTime;
          this.prescriptionTimerP = res.data.arriveTime;
          this.carrierPickUp = res.data.downStreamPickPay;
          this.carrierSend = res.data.downStreamSendPay;
          this.transportationfeepayable = res.data.downStreamLinePay;
          this.contractPriceRemark = res.data.contractPriceRemark
        })
      }
      }
      
    }
    }
    
    
  },
  methods: {
    onClickLeft() {
      this.$router.back();
    },
    onSelect(val) {
      this.delivery = val.name;
      this.sheetTypeVal = val.index;
      this.kaPickup = val.index;
      if (val.index == 0) {
        this.kaArPickUp = 0;
      }
      console.log(val);
    },
    onSelectT(val) {
      this.deliveryout = val.name;
      this.sheetTypeTVal = val.index;
      this.KaDelivery = val.index;
      if (val.index == 0) {
        this.kaArSend = 0;
      }
      console.log(val);
    },
    sheetType() {
      this.showType = true;
    },
    Tab(val) {
      this.TabArr = [val];
      if (val == "精拼报价") {
        // 精拼报价回显
        let num = 0;
        let kgs = 0;
        let m3s = 0;
        let orderinfo = [];
        if (!JSON.parse(sessionStorage.getItem("deliver"))) {
          Toast("请将发货地址填写完成再来查看！");
        } else if (!JSON.parse(sessionStorage.getItem("receiving"))) {
          Toast("请将收货地址填写完成再来查看！");
        } else {
          if (JSON.parse(sessionStorage.getItem("orderInfo"))) {
            orderinfo = JSON.parse(sessionStorage.getItem("orderInfo"));
            JSON.parse(sessionStorage.getItem("orderInfo")).map((item) => {
              num += Number(item.KaQuantity);
              kgs += Number(item.KaWeightKg);
              m3s += Number(item.KaVolume);
            });
          }
          let receiving = JSON.parse(sessionStorage.getItem("receiving"));
          let deliver = JSON.parse(sessionStorage.getItem("deliver"));
          console.log(this.$router.history.current.query.kauserId);
          let list = {
            KaGoodValues: 0, // 报价声明
            KaVolume: m3s,
            KaWeightKg: kgs,
            CneeAreaCode: receiving.KaUabArea,
            CneeProvinceCode: receiving.KaUabProvince,
            CneeCityCode: receiving.KaUabCity,
            ShrpAreaCode: deliver.KaUabArea,
            ShrpProvinceName: deliver.KaUabProvince,
            ShrpCityCode: deliver.KaUabCity,
            KaQuantity: num,
            LotteryID: "",
            KaSource: 7,
            userContractId:this.$router.history.current.query.kaUserContractId,
            KaUserId: this.$router.history.current.query.kauserId,
            stopOverList: JSON.parse(sessionStorage.getItem("stopOverList")).reverse(),
            kaGoodsTypeList: JSON.parse(sessionStorage.getItem("orderInfo")), // 货物清单
          };
          getPrices(list).then((res) => {
            console.log(res.kaTotalPrice);
            this.reaches = res.data.kaTotalPrice;
            this.reachesT = res.data.kaArPickUp;
            this.reachesS = res.data.kaArSend;
            this.reachesG = res.data.linePrice;
            this.reachesTimer = res.data.arriveTime;
            this.prescriptionMoney = res.data.downStreamTotalPay;
            this.prescriptionTimerP = res.data.arriveTime;
            this.prescriptionT = res.data.downStreamPickPay;
            this.prescriptionS = res.data.downStreamSendPay;
            this.prescriptionG = res.data.downStreamLinePay;
            this.contractPriceRemark = res.data.contractPriceRemark
          });
        }
      }
    },
    showT() {
      this.show = true;
    },
    mainpeople() {
      this.mainline = true;
    },
    ismainline() {
      this.showCarriage = true;
      // this.$router.push({
      //   path: "/carriageT",
      //   query: this.query
      // });
    },
    onclick(val) {
      this.checkArr = [val];
      this.mainlinePeople = this.checkArr[0];
      this.mainline = false;
      if (val == "精拼") {
        this.PushPlatformPc = 1;
        this.kaCarrierCompanyName = "";
        this.kaCarrierContactName = "";
        this.kaCarrierContactMobile = "";
        this.carrierNumber = "";
        this.showFlag = true;
      } else if (val == "直客承运商") {
        this.PushPlatformPc = 3;
        this.showFlag = false;
      }
    },
    Tpeopleonclick(val) {
      this.TpeoplecheckArr = [val];
      this.pickup = this.TpeoplecheckArr[0];
      this.Tpeople = false;
      if (val == "短驳") {
        this.kaIspickUp = 0;
        this.carrierPickUp = null;
      } else if (val == "精拼承运商" || val == "直客承运商") {
        this.kaIspickUp = 1;
      }
    },
    Speopleonclick(val) {
      this.SpeoplecheckArr = [];
      this.SpeoplecheckArr.push(val);
      this.pickdown = this.SpeoplecheckArr[0];
      this.Speople = false;
      if (val == "短驳") {
        this.kaIssend = 0;
        this.carrierSend = null;
      } else if (val == "精拼承运商" || val == "直客承运商") {
        this.kaIssend = 1;
      }
    },
    Tman() {
      this.Tpeople = true;
    },
    Sman() {
      this.Speople = true;
    },
    Isflag(val) {
      this.showCarriage = false;
    },
    backpage(val) {
      console.log(val);
      this.mainMan = val.kaCarrierCompanyName;
      this.kaCarrierCompanyName = val.kaCarrierCompanyName;
      this.kaCarrierId = val.kaCarrierId;
      this.mainuser = val.kaCarrierContactName;
      this.kaCarrierContactName = val.kaCarrierContactName;

      this.mainlinePeopleTel = val.kaCarrierContactMobile;
      this.kaCarrierContactMobile = val.kaCarrierContactMobile;

      this.checkArr = ["直客承运商"];
      this.mainlinePeople = "直客承运商";
    },
    onOK() {
      console.log(this.TabArr.filter((item) => item == "人工报价").length);
      if (this.TabArr.filter((item) => item == "人工报价").length) {
        let list = {
          isManual: 1, // 0-系统估价  1-人工估价
          kaPickup: this.kaPickup, // 人工上游是否提货
          kaArPickUp: this.sheetTypeVal == 1 ? this.deliveryMoney : 0, // 人工上游提货费
          KaDelivery: this.KaDelivery, // 人工上游是否送货
          kaArSend: this.sheetTypeTVal ? this.deliveryoutMoney : 0, // 人工上游发货费
          kaArFreight: this.kaArFreight, // 人工上游干线运输
          priceTime: this.priceTime, // 人工上游时效
          PushPlatformPc: this.PushPlatformPc, // 人工干线承运商
          PushPlatform: this.PushPlatformPc,
          kaCarrierId: this.kaCarrierId, // 承运商ID
          kaCarrierCompanyName: this.kaCarrierCompanyName, // 人工下游直客承运商名称
          kaCarrierContactName: this.kaCarrierContactName, // 人工下游直客承运商联系人
          kaCarrierContactMobile: this.kaCarrierContactMobile, // 人工下游直客联系人手机号
          carrierNumber: this.carrierNumber, // 人工下游直客承运商运单号
          carrierPrice: this.carrierPrice, // 人工下游干线运输
          kaIspickUp: this.kaIspickUp, // 人工下游是否提货
          kaIssend: this.kaIssend, // 人工下游是否送货
          carrierPickUp: this.carrierPickUp, //  人工下游提货费
          carrierSend: this.carrierSend, // 人工下游送货费
          remark: this.contractPriceRemark,
          TabArr: ["人工报价"],
        };
        sessionStorage.setItem("feed", JSON.stringify(list));
        if (this.$router.history.current.query.state == 1) {
          this.$router.push({
            path: "/details",
            query: { orderId: this.$router.history.current.query.orderId },
          });
        } else {
          this.$router.push({
            path: "/addList",
            query: this.$router.history.current.query,
          });
        }

        if(this.sheetTypeVal == 1){
          let deliver = JSON.parse(sessionStorage.getItem("deliver_checkArr"));
          if (!deliver.filter((item) => item == "需要提货").length) {
            deliver.push("需要提货");
            sessionStorage.setItem("deliver_checkArr", JSON.stringify(deliver));
          }
        }else{
          let arr = []
          JSON.parse(sessionStorage.getItem("deliver_checkArr")).map(item =>{
            if(item != '需要提货'){
              arr.push(item)
            }
          })
          sessionStorage.setItem("deliver_checkArr", JSON.stringify(arr));
        }


        if(this.sheetTypeTVal == 1){
          if (JSON.parse(sessionStorage.getItem("receiving_checkArr"))!=null) {
            let receiving = JSON.parse(
              sessionStorage.getItem("receiving_checkArr")
            );
            if (!receiving.filter((item) => item == "需要送货").length) {
              receiving.push("需要送货");
              sessionStorage.setItem(
                "receiving_checkArr",
                JSON.stringify(receiving)
              );
            }
          }

        }else{
          let arrs = []
          JSON.parse(sessionStorage.getItem("receiving_checkArr")).map(item =>{
            if(item != '需要送货'){
              arrs.push(item)
            }
          })
          sessionStorage.setItem("receiving_checkArr", JSON.stringify(arrs));
        }
      } else {
        if (!JSON.parse(sessionStorage.getItem("deliver"))) {
          Toast("发货地址为空！暂不支持使用精拼报价！");
          return false;
        } else if (!JSON.parse(sessionStorage.getItem("receiving"))) {
          Toast("收货地址为空！暂不支持使用精拼报价！");
          return false;
        }
        let list = {
          isManual: 0, // 0-系统估价  1-人工估价
          KaPickup: null, // 人工上游是否提货
          // KaArPickUp: this.reachesT, // 人工上游提货费
          KaDelivery: null, // 人工上游是否送货
          TabArr: ["精拼报价"],
          JPSmoney: this.reaches,
          JPXmoney: this.prescriptionMoney,
          remark: this.contractPriceRemark,
          // kaArSend: this.reachesS, // 人工上游发货费
          // KaArFreight: this.reachesG, // 人工上游干线运输
          // linePrice: this.reachesG, // 人工上游干线运输
          PushPlatform: 1, // 推送平台
          // carrierPrice: this.prescriptionG, // 人工下游干线运输
          // carrierPickUp: this.prescriptionT, //  人工下游提货费
          // carrierSend: this.prescriptionS, // 人工下游送货费
        };
        sessionStorage.setItem("feed", JSON.stringify(list));


        if(this.sheetTypeVal == 1){
          let deliver = JSON.parse(sessionStorage.getItem("deliver_checkArr"));
          if (!deliver.filter((item) => item == "需要提货").length) {
            deliver.push("需要提货");
            sessionStorage.setItem("deliver_checkArr", JSON.stringify(deliver));
          }
        }else{
          let arr = []
          JSON.parse(sessionStorage.getItem("deliver_checkArr")).map(item =>{
            if(item != '需要提货'){
              arr.push(item)
            }
          })
          sessionStorage.setItem("deliver_checkArr", JSON.stringify(arr));
        }


        if(this.sheetTypeTVal == 1){
          if (JSON.parse(sessionStorage.getItem("receiving_checkArr"))!=null) {
            let receiving = JSON.parse(
              sessionStorage.getItem("receiving_checkArr")
            );
            if (!receiving.filter((item) => item == "需要送货").length) {
              receiving.push("需要送货");
              sessionStorage.setItem(
                "receiving_checkArr",
                JSON.stringify(receiving)
              );
            }
          }

        }else{
          let arrs = []
          JSON.parse(sessionStorage.getItem("receiving_checkArr")).map(item =>{
            if(item != '需要送货'){
              arrs.push(item)
            }
          })
          sessionStorage.setItem("receiving_checkArr", JSON.stringify(arrs));
        }


        // if (JSON.parse(sessionStorage.getItem("deliver_checkArr"))!=null) {
        //   let deliver = JSON.parse(sessionStorage.getItem("deliver_checkArr"));
        //   if (!deliver.filter((item) => item == "需要提货").length) {
        //     deliver.push("需要提货");
        //     sessionStorage.setItem("deliver_checkArr", JSON.stringify(deliver));
        //   }
        // }

        // if (JSON.parse(sessionStorage.getItem("receiving_checkArr"))!=null) {
        //   let receiving = JSON.parse(
        //     sessionStorage.getItem("receiving_checkArr")
        //   );
        //   if (!receiving.filter((item) => item == "需要送货").length) {
        //     receiving.push("需要送货");
        //     sessionStorage.setItem(
        //       "receiving_checkArr",
        //       JSON.stringify(receiving)
        //     );
        //   }
        // }
        if (this.$router.history.current.query.state == 1) {
          this.$router.push({
            path: "/details",
            query: { orderId: this.$router.history.current.query.orderId },
          });
        } else {
          this.$router.push({
            path: "/addList",
            query: this.$router.history.current.query,
          });
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  padding: 44px 0 70px 0;
  box-sizing: border-box;
  overflow: scroll;
}
/deep/.van-field__label {
  color: #000;
}
.count {
  margin-top: 10px;
  background: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
  border-radius: 5px;
}
.buton {
  padding: 8px 16px;
  box-sizing: border-box;
  display: flex;
  border-radius: 5px;
  justify-content: space-around;
  background: #fff;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  .butonO {
    background: #fff;
    width: 328px;
    height: 44px;
    border: 1px solid #f18d00;
    border-radius: 5px;
    color: #f18d00;
  }
  .butonT {
    background: #f18d00;
    width: 328px;
    height: 44px;
    margin-left: 10px;
    border-radius: 5px;
    border: 1px solid #f18d00;
  }
}
.box_added {
  box-sizing: border-box;
  background: #fff;
  margin-top: 10px;
  .checkSteper {
    padding: 10px 10px;
    box-sizing: border-box;
    font-size: 15px;
    background: #fff;
    box-sizing: border-box;
    ul {
      display: flex;
      li {
        border: 1px solid #f3f3f3;
        color: #666666;
        width: 100px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        margin-right: 18px;
        background: #f3f3f3;
        border-radius: 4px;
      }
      .active {
        border: 0.5px solid #f18d00;
        color: #f18d00;
        background: #fffaf2;
      }
    }
  }
}
.box-Tab {
  .checkSteper {
    ul {
      display: flex;
      justify-content: space-around;
      align-items: center;
      p {
        color: #cccccc;
      }
      li {
        margin-right: 0;
      }
    }
  }
}
.fixed_box {
  width: 100%;
  height: 100%;
  display: flex;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 100;
}
</style>